﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FunkcionalnostiZetoni.aspx.cs"
    Inherits="Sio.Mdm.Web.Instalacija.Varnost.FunkcionalnostiZetoni" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>SIO - MDM :: Instalacija : Funkcionalnosti-Varnostni žetoni</title>

    <script type="text/javascript">
        var zetoniRenderer = function(value) {
            var r = StoreZetoni.getById(value);
            if (Ext.isEmpty(r)) { return ""; }
            return r.data.Naziv;
        };
    </script>

</head>
<body>
    <form id="FunkcionalnostiZetoni1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Store ID="StoreZetoni" runat="server">
        <reader>
				<ext:JsonReader IDProperty="VarnostniZetonId">
					<Fields>
						<ext:RecordField Name="VarnostniZetonId" Type="Int" />						
						<ext:RecordField Name="Naziv" Type="String" />
					</Fields>
				</ext:JsonReader>
			</reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
        <content>
            <ext:BorderLayout ID="BorderLayout1" runat="server">
                <North Collapsible="false" MinHeight="300" Split="true">
                    <sio:GridPanel ID="GridSplosniSeznam" runat="server" StripeRows="true" TrackMouseOver="true"
                        Height="300">
                        <Plugins>
                            <ext:GridFilters ID="GridFilters1" runat="server">
                                <Filters>
                                    <ext:NumericFilter DataIndex="FunkcionalnostId" />
                                    <ext:StringFilter DataIndex="Skupina" />
                                    <ext:StringFilter DataIndex="Naziv" />
                                </Filters>
                            </ext:GridFilters>
                        </Plugins>
                        <Store>
                            <ext:Store ID="StoreSplosniSeznam" runat="server">
                                <SortInfo Field="Naziv" />
                                <Reader>
                                    <ext:JsonReader IDProperty="FunkcionalnostId">
                                        <Fields>
                                            <ext:RecordField Name="FunkcionalnostId" Type="Int" />
                                            <ext:RecordField Name="Skupina" Type="String" />
                                            <ext:RecordField Name="Naziv" Type="String" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:RowNumbererColumn />
                                <ext:Column ColumnID="FunkcionalnostId" Hidden="true" Hideable="false" DataIndex="FunkcionalnostId">
                                </ext:Column>
                                <ext:Column ColumnID="Skupin" Header="Skupina" DataIndex="Skupina" Width="150">
                                </ext:Column>
                                <ext:Column ColumnID="Naziv" Header="Naziv funkcionalnosti" DataIndex="Naziv" Width="200">
                                </ext:Column>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                <Listeners>
                                    <RowSelect Handler="{#{StoreDodeljeno}.reload();}" Buffer="250" />
                                </Listeners>
                            </ext:RowSelectionModel>
                        </SelectionModel>
                    </sio:GridPanel>
                </North>
                <West Split="true">
                    <sio:GridPanel ID="GridDodeljeno" Title="Dodeljeni žetoni" Width="300"
                        EnableDragDrop="true" runat="server" StripeRows="true" TrackMouseOver="true">
                        <Plugins>
                            <ext:RowEditor ID="RowEditor1" runat="server" SaveText="Shrani" CancelText="Prekliči">
                                <DirectEvents>
                                        <AfterEdit OnEvent="UrediPodatke">
									        <ExtraParams>
										        <ext:Parameter Mode="Raw" Name="data" Value="r.data" />
									        </ExtraParams>
								        </AfterEdit>
                                </DirectEvents>
		                    </ext:RowEditor>                          
                            <ext:GridFilters ID="GridFiltersDodeljeno" runat="server">
                                <Filters>
                                    <ext:NumericFilter DataIndex="VarnostniZetonId" />
                                    <ext:BooleanFilter DataIndex="Branje"></ext:BooleanFilter>
                                    <ext:BooleanFilter DataIndex="Pisanje"></ext:BooleanFilter>
                                </Filters>
                            </ext:GridFilters>
                        </Plugins>
                        <Store>
                            <ext:Store ID="StoreDodeljeno" runat="server" OnRefreshData="GridDodeljenoRefresh">
                                <Reader>
                                    <ext:JsonReader IDProperty="VarnostniZetonId">
                                        <Fields>
                                            <ext:RecordField Name="VarnostniZetonId" Type="Int" />
                                            <ext:RecordField Name="FunkcionalnostId" Type="Int" />
                                            <ext:RecordField Name="Branje" Type="Boolean" />
                                            <ext:RecordField Name="Pisanje" Type="Boolean" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                                <BaseParams>
                                    <ext:Parameter Name="FunkcionalnostId" Value="#{GridSplosniSeznam}.getSelectionModel().hasSelection() ? #{GridSplosniSeznam}.getSelectionModel().getSelected().id : -1"
                                        Mode="Raw" />
                                </BaseParams>
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModel2" runat="server">
                            <Columns>
                                <ext:RowNumbererColumn />
                                <ext:Column ColumnID="VarnostniZetonId" Hidden="true" Hideable="false" DataIndex="VarnostniZetonId">
                                </ext:Column>

			<ext:Column Header="Naziv" DataIndex="VarnostniZetonId"  Width=150>
				<Renderer Fn="zetoniRenderer" />
				<Editor><ext:ComboBox ID="cbZetoni" runat="server"  TypeAhead="true" SelectOnFocus="true" Editable="true" Mode="Local" ForceSelection="true" 
						StoreID="StoreZetoni" ValueField="VarnostniZetonId" DisplayField="Naziv" /></Editor>
      </ext:Column>  
                    <ext:BooleanColumn 
                        Header="Branje" 
                        DataIndex="Branje" 
                        Align="Center" 
                        Width="50" 
                        TrueText="Da" 
                        FalseText="Ne">
                        <Editor>
                            <ext:Checkbox runat="server" />
                        </Editor>
                    </ext:BooleanColumn>                                
                                
                    <ext:BooleanColumn 
                        Header="Pisanje" 
                        DataIndex="Pisanje" 
                        Align="Center" 
                        Width="50" 
                        TrueText="Da" 
                        FalseText="Ne">
                        <Editor>
                            <ext:Checkbox runat="server" />
                        </Editor>
                    </ext:BooleanColumn>                                
                                                              
                                
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel2" runat="server" />
                        </SelectionModel>
                        <TopBar>
                            <ext:Toolbar ID="Toolbar2" runat="server" Width="500">
                                <Items>
                                    <ext:ToolbarFill />
                                    <sio:Button ID="Button1" runat="server" Text="Odstrani" Icon="ArrowRight">
                                        <DirectEvents>
                                            <Click OnEvent="OdstraniZetone" After="#{StoreDodeljeno}.reload();">
                                                <Confirmation ConfirmRequest="true" Message="Odstranim izbrane varnostne žetone?" />
                                                <ExtraParams>
                                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridDodeljeno}.getRowsValues({selectedOnly:true}))" />
                                                    <ext:Parameter Name="FunkcionalnostId" Value="#{GridSplosniSeznam}.getSelectionModel().hasSelection() ? #{GridSplosniSeznam}.getSelectionModel().getSelected().id : -1"
                                                        Mode="Raw" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </sio:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                    </sio:GridPanel>
                </West>
                <Center Split="true">
                    <sio:GridPanel ID="GridNeDodeljeno" Title="Nedodeljeni varnostni žetoni" runat="server" StripeRows="true"
                        Layout="Fit" Height="300">
                        <Plugins>
                            <ext:GridFilters ID="GridFilters2" runat="server">
                                <Filters>
                                    <ext:NumericFilter DataIndex="VarnostniZetonId" />
                                    <ext:StringFilter DataIndex="Naziv" />
                                </Filters>
                            </ext:GridFilters>
                        </Plugins>
                        <Store>
                            <ext:Store ID="StoreGridNeDodeljeno" runat="server">
                                <SortInfo Field="Naziv" />
                                <Reader>
                                    <ext:JsonReader IDProperty="VarnostniZetonId">
                                        <Fields>
                                            <ext:RecordField Name="VarnostniZetonId" Type="Int" />
                                            <ext:RecordField Name="Naziv" Type="String" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <ColumnModel ID="ColumnModel3" runat="server">
                            <Columns>
                                <ext:RowNumbererColumn />
                                <ext:Column ColumnID="VarnostniZetonId" Hidden="true" Hideable="false" DataIndex="VarnostniZetonId">
                                </ext:Column>
                                <ext:Column ColumnID="Naziv" Header="Naziv varnostnega žetona" DataIndex="Naziv" Width="150">
                                </ext:Column>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
                        </SelectionModel>
                        <TopBar>
                            <ext:Toolbar ID="Toolbar1" runat="server" Width="500">
                                <Items>
                                    <sio:Button ID="Button3" runat="server" Text="Dodaj" Icon="ArrowLeft">
                                        <DirectEvents>
                                            <Click OnEvent="DodajZetone" After="#{StoreGridNeDodeljeno}.reload(); #{StoreDodeljeno}.reload();">
                                                <Confirmation ConfirmRequest="true" Message="Dodam izbrane varnostne žetone?" />
                                                <ExtraParams>
                                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridNeDodeljeno}.getRowsValues({selectedOnly:true}))" />
                                                    <ext:Parameter Name="FunkcionalnostId" Value="#{GridSplosniSeznam}.getSelectionModel().hasSelection() ? #{GridSplosniSeznam}.getSelectionModel().getSelected().id : -1"
                                                        Mode="Raw" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </sio:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                    </sio:GridPanel>
                </Center>
            </ext:BorderLayout>
        </content>
    </ext:Viewport>
    </form>
</body>
</html>
